﻿using System;
using System.Net;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Media.Animation;

namespace RaisingStudio.SmallProgram.Library
{
    public static class Misc
    {
        public static void BeginAnimation(this DependencyObject element, DependencyProperty property, Timeline timeline)
        {
            if (timeline != null)
            {
                Storyboard storyboard = new Storyboard();
                Storyboard.SetTarget(timeline, element);
                Storyboard.SetTargetProperty(timeline, new PropertyPath(property));
                storyboard.Children.Add(timeline);
                storyboard.Begin();
            }
        }

        public static System.Net.WebResponse GetResponse(this System.Net.WebRequest request)
        {
            IAsyncResult asyncResult = request.BeginGetResponse(null, null);
            asyncResult.AsyncWaitHandle.WaitOne();
            return request.EndGetResponse(asyncResult);
        }
    }
}

